<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="../../css/style.css" rel="stylesheet" type="text/css" />
  <!--axios-->
  <script type="text/javascript" src="../../js/axios.js"></script>
  <script type="text/javascript" src="../../js/jquery-3.3.1.js"></script>
  <script>
    $(function (){
      view();
    })
    function getParameter(name) {
      var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)","i");
      var r = location.search.substr(1).match(reg);
      if (r!=null) return (r[2]); return null;
    }

    function view() {
      let orderId = getParameter("orderId");
      var url="http://121.37.227.40:8000/"
      axios({
        url:url+'marketing/queryOrderView',
        method:"POST",
        data:{
        },
        params:{
          orderId:orderId
        },
        dataType:"JSON"
      }).then(function (rel) {
        rel = rel.data
        let data = rel.resultData[0];
        let orderId=data.orderId
        let status = data.status;
        if (data.status == 0) {
          status = "未审核";
        } else if (data.status == 1) {
          status = "审核中";
        } else if (data.status == 2) {
          status = "审核通过";
        }
        let state;
        if (data.ckWarehouse!=null){
        state = data.ckWarehouse.state;
        if (state == 1) {
          state = "未发货";
        } else if (data.status == 2) {
          state = "已发货";
        } else if (data.status == 3) {
          state = "已回款";
        }else if (data.status == 4) {
          state = "取消订单";
        }else if (data.status == 5) {
          state = "已退货";
        }
        }else {
          state = ""
        }
        let ckWarehouse = {
          warehouse : { cName: data.ckWarehouse!=null ? data.ckWarehouse.warehouse!=null ? data.ckWarehouse.warehouse.cName : '' : '' },
          user: { uName: data.ckWarehouse!=null ? data.ckWarehouse.user!=null ? data.ckWarehouse.user.uName : '' : ''},
          cdate: data.ckWarehouse!=null ? data.ckWarehouse.cdate : ''
        }
        let str = '<div class="formtitle"><span>订购单信息</span></div>'
        str += '<ul class="forminfo">\n' +
                '    <li>\n' +
                '      <label>订单编号</label>\n' +
                '      <cite>'+ data.orderId+'</cite>\n' +
                '    </li>\n' +
                '    <li>\n' +
                '      <label>客户姓名</label>\n' +
                '      <cite><a href="javascript:void(0)" title="点击查看客户详细信息" class="tablelink" onclick="cView('+data.customId+')">'+data.customName.customName+'</a></cite>\n' +
                '    </li>\n' +
                '    <li>\n' +
                '      <label>联系电话</label>\n' +
                '      <cite>'+ data.customName.telephone+'</cite>\n' +
                '    </li>\n' +
                '    <li>\n' +
                '      <label>订购时间</label>\n' +
                '      <cite>'+data.orderTime +'</cite>\n' +
                '    </li>\n' +
                '    <li>\n' +
                '      <label>总金额</label>\n' +
                '       <cite>'+data.orderMoney +'</cite>\n' +
                '    </li>\n' +
                '    <li>\n' +
                '      <label>操作人</label>\n' +
                '      <cite>'+(data.operator == null ? '':data.operator.uName)+'</cite>\n' +
                '    </li>\n' +
                '    <li>\n' +
                '      <label>审核状态</label>\n' +
                '      <cite>'+status+'</cite>\n' +
                '    </li>\n' +
                '    <li>\n' +
                '      <label>审核意见</label>\n' +
                '      <cite>'+data.opinion +'</cite>\n' +
                '    </li>\n' +
                '    <li>\n' +
                '      <label>审核人</label>\n' +
                '      <cite>'+(data.checker == null ? '':data.checker.uName) +'</cite>\n' +
                '    </li>\n' +
                '    <li>\n' +
                '      <label>审核时间</label>\n' +
                '      <cite>'+data.checkTime +' </cite>\n' +
                '    </li>\n' +
                '    <li>\n' +
                '      <label>出货仓库</label>\n' +
                '      <cite><a href="javascript:void(0)" title="点击查看仓库详细信息" class="tablelink" onclick="gostorageview(\''+orderId+'\')">'+ckWarehouse.warehouse.cName +'</a></cite>\n' +
                '    </li>\n' +
                '    <li>\n' +
                '      <label>出库时间</label>\n' +
                '      <cite>'+ ckWarehouse.cdate +'</cite>\n' +
                '    </li>\n' +
                '    <li>\n' +
                '      <label>出库人</label>\n' +
                '      <cite>'+ckWarehouse.user.uName+'</cite>\n' +
                '    </li>\n' +
                '    <li>\n' +
                '      <label>出库状态</label>\n' +
                '      <cite>'+state+'</cite>\n' +
                '    </li>\n' +
                '  </ul>'
        axios({
          url:url+'marketing/queryOrderDetails',
          method:"POST",
          data:{
          },
          params:{
            orderId:orderId
          },
          dataType:"JSON"
        }).then(function (rm) {
            rm=rm.data;
            str+='<table class="tablelist">\n' +
                    '      <thead>\n' +
                    '        <tr>\n' +
                    '          <th>序号</th>\n' +
                    '          <th>品牌</th>\n' +
                    '          <th>类型</th>\n' +
                    '          <th>型号</th>\n' +
                    '          <th>数量</th>\n' +
                    '          <th>单位</th>\n' +
                    '          <th>单价</th>\n' +
                    '          <th>金额</th>\n' +
                    '        </tr>\n' +
                    '      </thead>\n' +
                    '      <tbody>'
          for (var i=0;i<rm.resultData.length;i++){
            var data=rm.resultData[i]
            str+='<tr>\n' +
                    '          <td>'+(i+1)+'</td>\n' +
                    '          <td>'+data.product.type.brand.brandName+'</td>\n' +
                    '          <td>'+data.product.type.typeName+'</td>\n' +
                    '          <td>'+data.product.productModel+'</td>\n' +
                    '          <td>'+data.purchaseNum+'</td>\n' +
                    '          <td>台</td>\n' +
                    '          <td>'+ data.proPrice +'</td>\n' +
                    '          <td>'+data.proTotal+'</td>\n' +
                    '        </tr>'

          }
          str+='</tbody>\n' +
                  '  </table>\n' +
                  '  <div style="margin-top:20px; margin-left:20px;">\n' +
                  '  <input name="" type="button" class="btn" value="返回" onclick="window.history.go(-1);"/>\n' +
                  '  </div>'
          $("#dview").html(str)
          $('.tablelist tbody tr:odd').addClass('odd');
        })
      })
    }
    function gostorageview(orderId) {
      location.href="../../storage/storage/storageView.html?orderId="+orderId
    }
    function cView(customId) {
      var url="http://121.37.227.40:8000/"
      axios({
        url:url+'marketing/queryAddress',
        method:"POST",
        data:{
        },
        params:{
          customId:customId
        },
        dataType:"JSON"
      }).then(function (rel){
        rel=rel.data
        var data=rel.resultData
        goview(customId,data.city.province.pName,data.city.cName)
      })
    }
    function goview(customId,province,city){
      location.href="../customer/customerView.html?customid="+customId+"&province="+province+"&city="+city
    }
  </script>
</head>

<body>
<div class="place"> <span>位置：</span>
  <ul class="placeul">
    <li>营销管理</li>
    <li>订购单管理</li>
    <li>订购单详情</li>
  </ul>
</div>
<div class="formbody" id="dview">
<!--  <div class="formtitle"><span>订购单信息</span></div>-->
<!--  <ul class="forminfo">-->
<!--    <li>-->
<!--      <label>订单编号</label>-->
<!--      <cite>DJ201711180001</cite>-->
<!--    </li>-->
<!--    <li>-->
<!--      <label>客户姓名</label>-->
<!--      <cite><a href="../../market/customer/customerView.html" title="点击查看客户详细信息" class="tablelink">王金平</a></cite>-->
<!--    </li>-->
<!--    <li>-->
<!--      <label>联系电话</label>-->
<!--      <cite>17370899727</cite>-->
<!--    </li>-->
<!--    <li>-->
<!--      <label>订购时间</label>-->
<!--      <cite>2017-11-18 15:36:10</cite>-->
<!--    </li>-->
<!--    <li>-->
<!--      <label>总金额</label>-->
<!--       <cite>￥9,876,582</cite>-->
<!--    </li>-->
<!--    <li>-->
<!--      <label>操作人</label>-->
<!--      <cite>关羽</cite>-->
<!--    </li>-->
<!--    <li>-->
<!--      <label>审核状态</label>-->
<!--      <cite>已审核通过</cite>-->
<!--    </li>-->
<!--    <li>-->
<!--      <label>审核意见</label>-->
<!--      <cite>做的很详细，同意通过</cite>-->
<!--    </li>-->
<!--    <li>-->
<!--      <label>审核人</label>-->
<!--      <cite>曹操</cite>-->
<!--    </li>-->
<!--    <li>-->
<!--      <label>审核时间</label>-->
<!--      <cite>2017-01-30 12:05:05</cite>-->
<!--    </li>-->
<!--    <li>-->
<!--      <label>出货仓库</label>-->
<!--      <cite><a href="../storage/storageView.html" title="点击查看客户详细信息" class="tablelink">南京21号仓库</a></cite>-->
<!--    </li>-->
<!--    <li>-->
<!--      <label>出库时间</label>-->
<!--      <cite>2013-09-09 15:05:05</cite>-->
<!--    </li>-->
<!--    <li>-->
<!--      <label>出库人</label>-->
<!--      <cite>朱元璋</cite>-->
<!--    </li>-->
<!--    <li>-->
<!--      <label>出库状态</label>-->
<!--      <cite>已回款</cite>-->
<!--    </li>-->
<!--  </ul>-->
<!--  <table class="tablelist">-->
<!--      <thead>-->
<!--        <tr>-->
<!--          <th>序号</th>-->
<!--          <th>品牌</th>-->
<!--          <th>类型</th>-->
<!--          <th>型号</th>-->
<!--          <th>数量</th>-->
<!--          <th>单位</th>-->
<!--          <th>单价</th>-->
<!--          <th>金额</th>-->
<!--        </tr>-->
<!--      </thead>-->
<!--      <tbody>-->
<!--        <tr>-->
<!--          <td>1</td>-->
<!--          <td>联想</td>-->
<!--          <td>笔记本电脑</td>-->
<!--          <td>T470</td>-->
<!--          <td>10</td>-->
<!--          <td>台</td>-->
<!--          <td>9998</td>-->
<!--          <td>99980</td>-->
<!--        </tr>-->
<!--        <tr>-->
<!--          <td>2</td>-->
<!--          <td>联想</td>-->
<!--          <td>笔记本电脑</td>-->
<!--          <td>X260</td>-->
<!--          <td>5</td>-->
<!--          <td>台</td>-->
<!--          <td>5500</td>-->
<!--          <td>27500</td>-->
<!--        </tr>-->
<!--      </tbody>-->
<!--  </table>-->
<!--  <div style="margin-top:20px; margin-left:20px;">-->
<!--  <input name="" type="button" class="btn" value="返回" onclick="window.history.go(-1);"/>-->
<!--  </div>-->
</div>
<script type="text/javascript">
	$('.tablelist tbody tr:odd').addClass('odd');
</script>
</body>
</html>
